Let $x$ and $y$ be positive real numbers.  Find the minimum value of
\[\left( x + \frac{1}{y} \right) \left( x + \frac{1}{y} - 2018 \right) + \left( y + \frac{1}{x} \right) \left( y + \frac{1}{x} - 2018 \right).\]
Solution: By QM-AM,
\[\sqrt{\frac{(x + \frac{1}{y})^2 + (y + \frac{1}{x})^2}{2}} \ge \frac{(x + \frac{1}{y}) + (y + \frac{1}{x})}{2},\]so
\[\left( x + \frac{1}{y} \right)^2 + \left( y + \frac{1}{x} \right)^2 \ge \frac{1}{2} \left( x + \frac{1}{y} + y + \frac{1}{x} \right)^2.\]Then
\begin{align*}
&\left( x + \frac{1}{y} \right) \left( x + \frac{1}{y} - 2018 \right) + \left( y + \frac{1}{x} \right) \left( y + \frac{1}{x} - 2018 \right) \\
&= \left( x + \frac{1}{y} \right)^2 + \left( y + \frac{1}{x} \right)^2 - 2018 \left( x + \frac{1}{y} \right) - 2018 \left( y + \frac{1}{x} \right) \\
&\ge \frac{1}{2} \left( x + \frac{1}{y} + y + \frac{1}{x} \right)^2 - 2018 \left( x + \frac{1}{y} + y + \frac{1}{x} \right) \\
&= \frac{1}{2} u^2 - 2018u \\
&= \frac{1}{2} (u - 2018)^2 - 2036162,
\end{align*}where $u = x + \frac{1}{y} + y + \frac{1}{x}.$

Equality occurs when $u = 2018$ and $x = y.$  This means $x + \frac{1}{x} = 1009,$ or $x^2 - 1009x + 1 = 0.$  We can check that this quadratic has real roots that are positive, so equality is possible.  Thus, the minimum value is $\boxed{-2036162}.$